using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;

namespace Antu.Business.Admin
{
    public class Implement
    {
        public static String ComputeMD5(String data)
        {
            StringBuilder result = new StringBuilder(); 
            ASCIIEncoding ae= new ASCIIEncoding();
            MD5CryptoServiceProvider md5CSP = new MD5CryptoServiceProvider();
            byte[] md5data;

            try
            {               
                md5data = md5CSP.ComputeHash(ae.GetBytes(data));

                for (int i = 0; i < md5data.Length; i++)
                {
                    result.AppendFormat("{0:x2}", md5data[i]);
                }
                return result.ToString();
            }
            catch (Exception err)
            {
                throw err;
            }
            finally
            {
                md5CSP.Clear();
            }
        }
    }
}
